<?php $this->load->view('common/head');?>
<?php $this->load->view('common/navbar');?>
<div class="panel panel-default">
  <!-- Default panel contents -->
  <div class="panel-heading">专营店基本信息</div>

  <!-- Table -->
  <table class="table table-condensed">
    <tbody>
      <tr>
        <td class="bg-primary col-md-1">所属区：</td>
        <td><?php echo $storeData['region'] ?></td>
      </tr>
      <tr>
        <td class="bg-primary col-md-1">专营店：</td>
        <td><?php echo $storeData['storeName'] ?></td>
      </tr>
      <tr>
        <td class="bg-primary col-md-1">年度额度：</td>
        <td><?php echo $procData['yearMoney'] ?></td>
      </tr>
    </tbody>
  </table>
</div>
<table class="table table-condensed table-bordered">
  <tbody>
    <tr>
      <td class="bg-primary col-md-3">双月申报</td>
    </tr>
  </tbody>
</table>
<form class="form-horizontal margin-top-10" name="add" id="add" action="<?php echo $this->input->server('REQUEST_URI'); ?>" method="post">
<input type="hidden" name="procId" id="procId" value="<?=$procData['id']?>">
<?php $voucherIds = array(); ?>
<?php foreach ($projectList as $k => $v): ?>
<?php $v['itemList'] = array_values($v['itemList']); ?>
<div style="border:1px solid #cccccc; padding: 20px; margin-bottom: 10px;">
    <table class="table table-condensed table-bordered mb27">
      <thead class="text-center">
          <tr>
            <td class="bg-primary text-center">投放编号</td>
            <td class="bg-primary text-center">投放类型</td>
            <td class="bg-primary text-center">投放规格</td>
            <td class="bg-primary text-center">地址</td>
            <td class="bg-primary text-center">合同时间</td>
            <td class="bg-primary text-center">合同金额</td>
          </tr>
        </thead>
      <tbody class="text-center">
        <tr>
          <td><?=$v['id']?></td>
          <td><?=$v['mediaTypeStr']?></td>
          <td><?=$v['mediaSize']?></td>
          <td><?=$v['address']?></td>
          <td><?=$v['contractStart']?>--<?=$v['contractEnd']?></td>
          <td><?=$v['applyMoney']?></td>
        </tr>
      </tbody>
    </table>
    <?php foreach ($v['itemList'] as $itemK => $itemData): ?>
    <?php $itemData['voucher'] = array_values((array)$itemData['voucher']); ?>
    <table class="table table-condensed">
      <thead class="text-center">
        <tr>
          <td class="bg-primary text-center">所属双月</td>
          <td class="bg-primary text-center" colspan="4">自证照片</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td class="text-center col-md-1" rowspan="6"><?=$itemData['timeUnitStr']?></td>
          <td class="text-center" colspan="3">仅能上传格式为.jpg.png，大小不能超过3M。至少上传一张，最多可上传5张，其中至少有1张照片带当天日期的报纸报头；如遇特殊情况中止使用，需上传相关证明材料</td>
        </tr>
        <?php for ($i=1; $i <= 5; $i++) { ?>
        <tr>
          <td class="col-md-1">自证照片<?=$i?></td>
          <td>
            <div id="voucher_<?=$itemData['id']?>_<?=$i?>ImgBox" style="width:200px;overflow:hidden;">
              <?php if ($itemData['voucher'][$i-1]['viewPath']) {?>
              <a target="_blank" href="<?=$itemData['voucher'][$i-1]['viewPath']?>" class="thumbnail">
                <img class="carousel-inner img-responsive img-rounded" src="<?=$itemData['voucher'][$i-1]['viewPath']?>">
              </a>
              <?php } ?>
            </div>
            <?php if (in_array($itemData['auditRs'], array(-1,0,3))): ?>
            <input type="hidden" id="voucher_<?=$itemData['id']?>_<?=$i?>FileId" name="voucher[<?=$itemData['id']?>][]" value="<?=$itemData['voucher'][$i-1]['id']?>" readonly="readonly">
            <input type="button" id="voucher_<?=$itemData['id']?>_<?=$i?>" value="上传" />
            <?php
              $voucherIds[] = 'voucher_'.$itemData['id'].'_'.$i;
            ?>
            <?php endif ?>
          </td>
        </tr>
        <?php } ?>
      </tbody>
    </table>
    <?php endforeach ?>
</div>
<?php endforeach ?>
<div class="text-center">
<button type="submit" class="btn btn-default btn-primary">提交</button>
<button class="btn btn-default btn-primary" type="button" onclick="window.location.href='<?=$breadcrumb[count($breadcrumb)-2]['url']?>'">返回</button>
</div>
</form>
<?php initUploadButtons($voucherIds, printUrl('Upload','uploadSave',array('dir'=>'image')), 'imgFile'); ?>
<script type="text/javascript">
  $(function(){
    initValidation();
    $("#itemId").change(function(){
      window.location.href='<?=printUrl('SpreadSettle','storeEdit',array('projectId'=>$_GET['projectId']))?>&itemId='+this.value;
    });
  });
  //初始化验证
function initValidation(){
  $('form[name="add"]').find("input,select,textarea").jqBootstrapValidation("destroy");
  $('form[name="add"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
      preventSubmit:false,
      submitSuccess: function (form, event) {
           event.preventDefault();
           ajaxFormSubmit('add');
       },
       submitError: function (form, event, errors) {
         event.preventDefault();
         }
    });
}
</script>
<?php $this->load->view('common/auditList', $this->viewData); ?>
<?php $this->load->view('common/foot');?>